var love
export default class road{
  constructor(_love){
    love = love || _love
    this.speed = 0.3 // px/ms
    this.lapCount = 5
    this.w = 1600
    this.h = 600
    this.offset = 0
    this.dash = [60,300]
  }
  setSpeed(){}
  update(dt){
    this.speed = this.playerCar.speed
    this.offset = this.offset + this.speed * dt
  }
  getLapPos(i){
    return (900 - this.h) / 2 + (i - 0.5) * (this.h / this.lapCount)
  }
  getLapPosTop(i){
    return (900 - this.h) / 2 + (i - 1) * (this.h / this.lapCount)
  }
  draw(){
    //love.graphics.setLineDash(this.dash)
    //love.graphics.setLineDashOffset(this.offset)
    love.graphics.setColor("#000000")
    for (var i = 1;i<=this.lapCount+1;++i){
      let offy = this.getLapPosTop(i)
      for (var j = 0;j<7;j++ ){
        let offset =  - this.offset % (this.dash[0] + this.dash[1]) + j * (this.dash[0] + this.dash[1])
        love.graphics.line(  offset, offy,  offset + this.dash[0], offy)
        //console.log(offset, offy, offset + this.dash[1], offy)
      }
     
    }
  }
}